package day05;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class MapOfArrayDemo {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Random rd = new Random();
        int num = sc.nextInt();
        int[] array = new int[num];
        for (int i = 0; i < array.length; i++) {
            array[i] = rd.nextInt(1001);
//                System.out.println(i+1+"\t"+array[i]);
        }

        Arrays.sort(array);//数组从小到大顺序排序
        pr(array);
        contrarypr(array);
        max(array);
        min(array);


    }
    //最大值
    private static void max(int array[]){
        int id = 1;
        int max=array[0];
        for (int i = 1; i < array.length; i++) {
            if (array[i]>max){
                max = array[i];
                id = i+1;
            }
//            System.out.println(id+"\t"+max);
        }
        System.out.println(id+"\t"+max);

    }
    //最小值
    private static void min(int array[]){
        int id = 1;
        int min=array[0];
        for (int i = 1; i < array.length; i++) {
            if (array[i]<min){
                min = array[i];
                id = i+1;
            }
//            System.out.println(id+"\t"+max);
        }
        System.out.println(id+"\t"+min);

    }
    //输出数组内容
    public static void pr(int array[]){
        for (int i = 0; i < array.length; i++) {
            System.out.println(i+1+"\t"+array[i]);
        }
    }
    //反向输出数组内容
    private static void contrarypr(int array[]){
        for (int i = array.length-1,j = 1; i >= 0; i--,j++) {
            System.out.println(j+"\t"+array[i]);
        }
    }
}
